var common = require('../../utils/util.js');

Page({
  /**
   * 页面的初始数据
   */
  data: {
    content: "",
    id: "",
    title: "",
    create_time: "",
    // 列表分页参数
    currentNo: 1,
    isajax: false,
    listarr: [],
    isnodata: false,
    pagesize: 10,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let id = options.id || "";
    this.setData({
      id
    })
    this.getDetail();
  },
  onShow() {
    this.change_data_list();
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.get_data_list();
  },
  getDetail() {
    let that = this;
    wx.showLoading({
      title: "加载中",
    });
    common.getData_user(common.config.NewsDetail, {
      news_id: that.data.id,
    }, "post", function (res) {
      wx.hideLoading();
      that.setData({
        content: res.content,
        title: res.title,
        create_time: res.create_time,
        cover: res.cover,
      });
    });
  },
  /**初次请求，列表数据**/
  change_data_list: function () {
    common.changelistdata_user(this, common.config.NewsComment, {
      news_id: this.data.id,
    });
  },

  /**下拉加载更多，列表数据**/
  get_data_list: function () {
    common.getlistdata_user(this, common.config.NewsComment, {
      news_id: this.data.id,
    });
  },
  
  onComment() {
    wx.navigateTo({
      url: `/pages/news/addComment?id=${this.data.id}`,
    })
  }
});